<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise race</title>
</head>
<body>
    <script>
        // let p1 = new Promise((resolve,reject)=>{
        //     resolve('ok');
        // })
        let p4 = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                resolve('ok');
            },1000);
        })
        let p2=Promise.resolve('success');
        let p3= Promise.resolve('yes');

        // race 谁先改变状态，谁就决定结果 
        // const result1 = Promise.race([p1,p2,p3]);
        // p1 先改变 结果是ok
        // console.log(result1);

        const result2 = Promise.race([p4,p2,p3]);
        // p4加了定时器 所有 p2 先改变 结果是 success
        console.log(result2);
    </script>
</body>
</html>